.bin-tree-org {
  &-wrap {
    display: inline-block;
    padding: 15px;
    background-color: #fff;
  }
  display: table;
  text-align: center;
  &:before, &:after {
    content: '';
    display: table;
  }
  &:after {
    clear: both;
  }

  &-node, &-node-children {
    position: relative;
    margin: 0;
    padding: 0;
    list-style-type: none;
    &:before, &:after {
      transition: all .3s;
    }
  }
  &-node {
    padding-top: 20px;
    display: table-cell;
    vertical-align: top;
    &.is-leaf, &.collapsed {
      padding-left: 10px;
      padding-right: 10px;
    }

    &:before, &:after {
      content: '';
      position: absolute;
      top: 0;
      left: 0;
      width: 50%;
      height: 19px;
    }

    &:after {
      left: 50%;
      border-left: 1px solid #ddd;
    }

    &:not(:first-child):before, &:not(:last-child):after {
      border-top: 1px solid #ddd;
    }

    &-label {
      position: relative;
      display: inline-block;
      .bin-tree-org-node-label-inner {
        cursor: pointer;
        padding: 10px 15px;
        text-align: center;
        border-radius: 2px;
        box-shadow: 0 1px 5px rgba(0, 0, 0, .15);
      }
    }
    &-btn {
      position: absolute;
      top: 100%;
      left: 50%;
      width: 20px;
      height: 20px;
      z-index: 10;
      background-color: #fff;
      border: 1px solid #ccc;
      border-radius: 50%;
      box-shadow: 0 0 2px rgba(0, 0, 0, .15);
      cursor: pointer;
      transition: all .3s ease;
      transform: translate(-50%, 50%);
      &:hover {
        background-color: #efefef;
      }

      &:before, &:after {
        content: '';
        position: absolute;
        background: #ccc;
      }

      &:before {
        top: 50%;
        left: 4px;
        right: 4px;
        height: 1px;
      }

      &:after {
        top: 4px;
        left: 50%;
        bottom: 4px;
        width: 1px;
      }

      &.expand:after {
        display: none;
      }
    }
  }
}
.collapsable .bin-tree-org-node.collapsed {
  padding-bottom: 30px;
  .bin-tree-org-node-label:after {
    content: '';
    position: absolute;
    top: 100%;
    left: 0;
    width: 50%;
    height: 20px;
    border-right: 1px solid #ddd;
  }
}
.bin-tree-org > .bin-tree-org-node {
  padding-top: 0;
  &:after {
    border-left: 0;
  }
}
.bin-tree-org-node-children {
  display: table;
  padding-top: 20px;
  &:before {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    width: 0;
    height: 20px;
    border-left: 1px solid #ddd;
  }
  &:after {
    content: '';
    display: table;
    clear: both;
  }
}

.horizontal {
  .bin-tree-org-node {
    display: table;
    padding-top: 0;
    padding-left: 20px;
    &.is-leaf, &.collapsed {
      padding-top: 10px;
      padding-bottom: 10px;
    }

    &:before, &:after {
      width: 19px;
      height: 50%;
    }

    &:after {
      top: 50%;
      left: 0;
      border-left: 0;
    }

    &:only-child:before {
      top: 0;
      border-bottom: 1px solid #ddd;
    }

    &:not(:first-child):before,
    &:not(:last-child):after {
      border-top: 0;
      border-left: 1px solid #ddd;
    }

    &:not(:only-child):after {
      border-top: 1px solid #ddd;
    }

  }

  .bin-tree-org-node-label {
    display: table-cell;
    vertical-align: middle;
  }

  &.collapsable .bin-tree-org-node.collapsed {
    padding-right: 30px;
    .bin-tree-org-node-label:after {
      top: 1px;
      left: 100%;
      width: 20px;
      height: 50%;
      border-right: 0;
      border-bottom: 1px solid #ddd;
    }
  }

  .bin-tree-org-node-btn {
    top: 50%;
    left: 100%;
    transform: translate(-50%, -50%);
    margin-left: 20px;
  }
  & > .bin-tree-org-node:only-child:before {
    border-bottom: 0;
  }

  .bin-tree-org-node-children {
    display: table-cell;
    padding-top: 0;
    padding-left: 20px;
    &:before {
      top: 50%;
      left: 0;
      width: 20px;
      height: 0;
      border-left: 0;
      border-top: 1px solid #ddd;
    }
    &:after {
      display: none;
    }
    & > .bin-tree-org-node {
      display: block;
    }
  }
}

